<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class MY_Controller extends CI_Controller {
	function __construct(){
		parent::__construct();
		$this->load->database();
	}
}
/**
* 
*/
class API_Controller extends MY_Controller
{
	
	function __construct()
	{
		parent::__construct();
		$this->load->helper('lw_helper');
		$this->config->load('myconfig');
		date_default_timezone_set("Asia/Shanghai");
	}
}
class AD_Controller extends MY_Controller{
	function __construct(){
		parent::__construct();
		$this->load->helper('lw_helper');
		$this->load->library('session');
		//检测登陆
		$aid = $this->session->userdata('aid');
		if(!$aid){
			Header("Location: /admin"); 
		}
	}
	/**
	 * 分页类
	 * @param int $total_rows 符合条件的总共多少记录
	 * @param int $uri_segment 取分页值参数
	 * @param int $per_page_num 每页显示记录数
	 */
	public function page($total_rows = 0, $per_page_num = 10) {
		$this->load->library('pagination');
		$config['reuse_query_string'] = true;
		$config['base_url'] = '/admin/user/index';
		$config['total_rows'] = $total_rows;
		$config['per_page'] = $per_page_num; //每页多少行
		$config['full_tag_open'] = '<ul class="pagination">';
		$config['full_tag_close'] = '</ul>';
		$config['num_links'] = 5;
		$config['num_tag_open'] = '<li>';
		$config['num_tag_close'] = '</li>';
		$config['cur_tag_open'] = '<li class="active"><a href="#">';
		$config['cur_tag_close'] = '</a></li>';
		$config['first_link'] = '首页';
		$config['first_tag_open'] = '<li>';
		$config['first_tag_close'] = '</li>';
		$config['last_link'] = '最后一页';
		$config['last_tag_open'] = '<li>';
		$config['last_tag_close'] = '</li>';
		$config['prev_link'] = '上一页';
		$config['prev_tag_open'] = '<li>';
		$config['prev_tag_close'] = '</li>';
		$config['next_link'] = '下一页';
		$config['next_tag_open'] = '<li>';
		$config['next_tag_close'] = '</li>';
		$config['attributes']['rel'] = FALSE;
		
		$config['page_query_string'] = false;
		$this->pagination->initialize($config);
		$links = $this->pagination->create_links();
		return $links;
	}
}